#!/bin/bash

实施 cbp2make 内部统一引用
cd /d/vc/UEStudio/src/tools/cbp2make_ai

echo "开始实施 cbp2make 内部统一引用..."

备份原项目文件
cp cbp2make_aicoder_wx30_64.cbp cbp2make_aicoder_wx30_64.cbp.backup2

创建新的项目文件，引用原 cbp2make 的文件
cat > cbp2make_aicoder_wx30_64.cbp << 'CPBEOF'

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="cbp2make AICoder wx30_64" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Default">
<Option output="bin/cbp2make_ai_wx30_64" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option object_output=".objs/wx30_64" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Wall" />
<Add option="-std=c++11" />
<Add option="-DAICODER_ENHANCED" />
<Add option="-m64" />
<Add option="-D__WXMSW__" />
<Add option="-DwxUSE_UNICODE" />
</Compiler>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-std=c++11" />
<Add option="-DAICODER_ENHANCED" />
<Add option="-m64" />
<Add option="-D__WXMSW__" />
<Add option="-DwxUSE_UNICODE" />
<!-- 引用原项目的包含路径 -->
<Add directory="../cbp2make/lib" />
<Add directory="../cbp2make/lib/tinyxml" />
<Add directory="../cbp2make/src" />
<!-- 当前项目的路径 -->
<Add directory="lib" />
<Add directory="src" />
</Compiler>
<Linker>
<Add option="-m64" />
</Linker>

text
	<!-- AI 增强独有的文件 -->
	<Unit filename="src/aicoder_enhancements.cpp" />
	
	<!-- 引用原 cbp2make 的核心文件 -->
	<Unit filename="../cbp2make/src/cbp2make.cpp" />
	<Unit filename="../cbp2make/src/cbproject.cpp" />
	<Unit filename="../cbp2make/src/cbworkspace.cpp" />
	<Unit filename="../cbp2make/src/makefile.cpp" />
	<Unit filename="../cbp2make/src/cbptarget.cpp" />
	<Unit filename="../cbp2make/src/cbpunit.cpp" />
	<Unit filename="../cbp2make/src/cbbuildcfg.cpp" />
	<Unit filename="../cbp2make/src/cbbuildmgr.cpp" />
	<Unit filename="../cbp2make/src/cbglobalvar.cpp" />
	<Unit filename="../cbp2make/src/cbhelper.cpp" />
	<Unit filename="../cbp2make/src/depsearch.cpp" />
	<Unit filename="../cbp2make/src/platforms.cpp" />
	<Unit filename="../cbp2make/src/toolchains.cpp" />
	<Unit filename="../cbp2make/src/buildtools.cpp" />
	
	<!-- 引用原 cbp2make 的库文件 -->
	<Unit filename="../cbp2make/lib/stlconfig.cpp" />
	<Unit filename="../cbp2make/lib/stlconvert.cpp" />
	<Unit filename="../cbp2make/lib/stlfutils.cpp" />
	<Unit filename="../cbp2make/lib/stlgpm.cpp" />
	<Unit filename="../cbp2make/lib/stlstrings.cpp" />
	<Unit filename="../cbp2make/lib/stlvariables.cpp" />
	<Unit filename="../cbp2make/lib/stringhash.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinystr.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinyxml.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinyxmlerror.cpp" />
	<Unit filename="../cbp2make/lib/tinyxml/tinyxmlparser.cpp" />
</Project>
</CodeBlocks_project_file>
CPBEOF

echo "项目文件已更新为引用原 cbp2make 的文件"

测试编译
echo "测试编译..."
g++ -o bin/cbp2make_ai_wx30_64_test
src/aicoder_enhancements.cpp
../cbp2make/src/*.cpp
../cbp2make/lib/*.cpp
../cbp2make/lib/tinyxml/*.cpp
-I../cbp2make/lib -I../cbp2make/lib/tinyxml -I../cbp2make/src -Isrc
-Wall -std=c++11 -DAICODER_ENHANCED
-m64 -D__WXMSW__ -DwxUSE_UNICODE

if [ -f "bin/cbp2make_ai_wx30_64_test.exe" ]; then
echo "✅ 编译成功!"
echo "测试功能..."
./bin/cbp2make_ai_wx30_64_test.exe --help | head -5
else
echo "❌ 编译失败，请检查错误信息"
fi

echo "实施完成!"
echo "现在 cbp2make_ai 项目引用原 cbp2make 的文件，消除了重复"
